package tpo.wmb.provider.controller;

import api.user.UserApi;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RestController;
import pojo.Area;
import pojo.User;
import pojo.Useraddress;
import tpo.wmb.provider.service.UserService;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class UserController implements UserApi {

    @Resource
    UserService userService;

    @Override
    public PageInfo<User> selectUserList(Map<String, Object> map) {
        int pageNum = Integer.parseInt(map.get("pageNum").toString());
        int pageSize = Integer.parseInt(map.get("pageSize").toString());
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = userService.selectUserList(map);
        return new PageInfo<>(list,3);
    }

    @Override
    public List<Integer> selectUserListInt(String s) {
        return userService.selectUserListInt(s);
    }

    @Override
    public List<User> selectUsers() {
        return userService.selectUsers();
    }

    @Override
    public User selectUser(Integer integer) {
        return userService.selectUser(integer);
    }

    @Override
    public Integer insertUser(User user) {
        return userService.insertUser(user);
    }

    @Override
    public Integer updateUser(User user) {
        return userService.updateUser(user);
    }

    @Override
    public Integer deleteUser(Integer integer) {
        return userService.deleteUser(integer);
    }

    @Override
    public List<Useraddress> selectAddressList(Integer integer) {
        return userService.selectAddressList(integer);
    }


    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++分割线---------------------------------------



    @Override
    public Useraddress selectAddress(Integer integer) {
        return userService.selectAddress(integer);
    }

    @Override
    public Integer insertAddress(Useraddress useraddress) {
        return userService.insertAddress(useraddress);
    }

    @Override
    public Integer updateAddress(Useraddress useraddress) {
        return userService.updateAddress(useraddress);
    }

    @Override
    public Integer deleteAddress(Integer integer) {
        return userService.deleteAddress(integer);
    }


    @Override
    public Useraddress selectDefalutAddress(Integer integer) {
        return userService.selectDefalutAddress(integer);
    }

    @Override
    public List<Area> selectUserArea(Integer integer) {
        return userService.selectUserArea(integer);
    }
}
